|
The Sierpinski carpet is a plane fractal first described by Wacław Sierpiński in 1916. The carpet is one generalization of the Cantor set to two dimensions; another is the Cantor dust. The technique of subdividing a shape into smaller copies of itself, removing one or more copies, and continuing recursively can be extended to other shapes. For instance, subdividing an equilateral triangle into four equilateral triangles, removing the middle triangle, and recursing leads to the Sierpinski triangle. In three dimensions, a similar construction based on cubes produces the Menger sponge. ==Construction== The construction of the Sierpinski carpet begins with a square. The square is cut into 9 congruent subsquares in a 3-by-3 grid, and the central subsquare is removed. The same procedure is then applied recursively to the remaining 8 subsquares, ''ad infinitum''. It can be realised as the set of points in the unit square whose coordinates written in base three do not both have a digit '1' in the same position. The process of recursively removing squares is an example of a finite subdivision rule. The Sierpinski carpet can also be created by iterating every pixel in a square and using the following algorithm to decide if the pixel is filled. The following implementation is valid C, C++, and Java. / * * * Decides if a point at a specific location is filled or not. This works by iteration first checking if * the pixel is unfilled in successively larger squares or cannot be in the center of any larger square. * @param x is the x coordinate of the point being checked with zero being the first pixel * @param y is the y coordinate of the point being checked with zero being the first pixel * @return 1 if it is to be filled or 0 if it is open */ int isSierpinskiCarpetPixelFilled(int x, int y) 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Sierpinski carpet」の詳細全文を読む スポンサード リンク
|